import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Demo(QWidget):
    def __init__(self,parent=None):
        super(Demo,self).__init__(parent)
        self.setWindowTitle('不规则窗口的展示')
        self.pix=QBitmap('./images/mask.png')
        self.resize(self.pix.size())
        self.setMask(self.pix)
    def paintEvent(self, event):
        painter=QPainter(self)

        #调用控件增加一个遮罩盖住所选区域以外的部分使他看起来是透明的
        painter.drawPixmap(0,0,self.pix.width(),self.pix.height(),QPixmap('./images/screen1.jpg'))
if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=Demo()
    win.show()
    sys.exit(app.exec_())